void initializeCPU()
{
 	OSCCONbits.SCS0 = 0;
    OSCCONbits.SCS1 = 1; 
    OSCCONbits.IRCF0 = 1;
    OSCCONbits.IRCF1 = 1;
    OSCCONbits.IRCF2 = 1;

    OSCCONbits.IDLEN = 0;

	TRISD=0X00;
	TRISC=0xFF;
	TRISB=0xFF;
	CMCON=0;
}

void initializeADC(void){
//ADCON0 CONFIGURATION
	//Select channel 0 CHS3:CHS0 -> 0000
	ADCON0bits.CHS3=0;
	ADCON0bits.CHS2=0;
	ADCON0bits.CHS1=0;
	ADCON0bits.CHS0=0;
	//Enable ADC
	ADCON0bits.ADON=1;	

	//ADCON1 CONFIGURATION
	ADCON1bits.VCFG1=0; //use VSS as - reference
	ADCON1bits.VCFG0=0;	//use VDD as + reference
	ADCON1bits.PCFG3=1;
	ADCON1bits.PCFG2=1;
	ADCON1bits.PCFG1=1;
	ADCON1bits.PCFG0=0;

	//ADCON2 CONFIGURATION
	ADCON2bits.ADFM=0;
	//Select 2TAD
	ADCON2bits.ACQT2=0;
	ADCON2bits.ACQT1=0;
	ADCON2bits.ACQT0=0;
	//select FRC (clock derived from A/D RC oscillator)
	ADCON2bits.ADCS2=0;
	ADCON2bits.ADCS1=0;
	ADCON2bits.ADCS0=0;    
}
	
